
import 'package:banner_carousel/banner_carousel.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';


class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  _HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
  List<BannerModel> listBanners = [
    BannerModel(imagePath: "images/kawayi.jpeg", id: "1"),
    BannerModel(id: "2",imagePath: "images/kawayi.jpeg",),
    BannerModel(imagePath: "images/kawayi.jpeg", id: "3"),
    BannerModel(imagePath: "images/kawayi.jpeg",id: "4"),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("首页"),
      ),
      body: Container(
        child: Column(
          children: [
            //轮播图
            BannerCarousel(
              banners: listBanners,
              onTap: (id) => {
                Fluttertoast.showToast(
                msg: id,
                ),
              }
            ),
            //列表
            SizedBox(
              height: 400, //超过高度会报错
              child: ListView.builder(
                  shrinkWrap: true,
                  padding: const EdgeInsets.all(20.0),
                  itemCount: 20,
                  itemExtent: 50.0, //强制高度为50.0
                  itemBuilder: (BuildContext context, int index) {
                    return  ListTile(
                      leading: Image.asset("images/kawayi.jpeg"),
                      title: Text("$index"),
                      subtitle: Text("hahah"),
                    );
                  }
              ),
            ),

          ],
        ),
      ),
    );

  }
}
